package com.lucenten.collect.gnss.entity;

import cn.quevo.common.entity.DoEntity;
import cn.quevo.common.enums.ResultStatusEnum;
import cn.quevo.common.exception.CheckParamsException;
import cn.quevo.common.lang.BooleanUtils;
import cn.quevo.common.lang.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.beetl.sql.core.annotatoin.Table;

/**
 * 卫星台站信息 实体BEAN
 *
 * @author July july_sky@foxmail.com
 * @version 1.0
 * @date 2019/04/26 22:44:38
 * @Copyright 湘豫（北京）科技有限公司版权所有.All Rights Reserved.
 */
@ApiModel(value = "SatelliteStation 卫星台站信息")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table(name = "t_satellite_station")
public class SatelliteStation extends DoEntity {

    /** 站点ID */
    @ApiModelProperty(value = "站点ID")
    private String stationId;
    /** 站点名称 */
    @ApiModelProperty(value = "站点名称")
    private String stationName;
    /** 经度 */
    @ApiModelProperty(value = "经度")
    private Double longitude;
    /** 纬度 */
    @ApiModelProperty(value = "纬度")
    private Double latitude;
    /** 时间间隔(秒) */
    @ApiModelProperty(value = "时间间隔(秒)")
    private Integer sampleInterval;
    /** 天线类型 */
    @ApiModelProperty(value = "天线类型")
    private String antennaType;
    /** 海拔高度 */
    @ApiModelProperty(value = "海拔高度")
    private Double antennaElevation;
    /** 天线高度 */
    @ApiModelProperty(value = "天线高度")
    private Double antennaHeight;
    /** 接收机类型 */
    @ApiModelProperty(value = "接收机类型")
    private String receiverType;
    /** 站点设备 */
    @ApiModelProperty(value = "站点设备")
    private String stationNaMech;
    /** 文件类型 */
    @ApiModelProperty(value = "文件类型")
    private String fileType;
    /** 省份 */
    @ApiModelProperty(value = "省份")
    private String province;
    /** 站点新名称 */
    @ApiModelProperty(value = "站点新名称")
    private String reStationName;
    /** 是否选择 */
    @ApiModelProperty(value = "是否选择")
    private String choseYn;

    /** X */
    @ApiModelProperty(value = "X")
    private Double x;
    /** Y */
    @ApiModelProperty(value = "Y")
    private Double y;
    /** Z */
    @ApiModelProperty(value = "z")
    private Double z;

    public static SatelliteStation getInstance(String stationId, String stationName) {
        SatelliteStation satelliteStation = new SatelliteStation();
        satelliteStation.setStationId(stationId);
        satelliteStation.setStationName(stationName);
        return satelliteStation;
    }

    /**
    * 公共参数验证
    */
    protected void validate() {
        if(StringUtils.isBlank(this.getStationId())){
            throw new CheckParamsException(6001, "站点ID不能为空");
        }
        if(StringUtils.isBlank(this.getStationName())){
            throw new CheckParamsException(6002, "站点名称不能为空");
        }
        if(StringUtils.isBlank(this.getSampleInterval())){
            this.setSampleInterval(0);
        }
        this.setChoseYn(StringUtils.isBlank(this.choseYn) || BooleanUtils.isTrue(this.choseYn) ? BooleanUtils.TRUE : BooleanUtils.FALSE);
    }

    /**
    * 新增参数验证
    */
    public void validateCreate() {
        this.validate();
    }

    /**
    * 修改参数验证
    */
    public void validateUpdate() {
        if (StringUtils.isBlank(this.getId())) {
            throw new CheckParamsException(ResultStatusEnum.RECORD_UNSELECTED);
        }
        this.validate();
    }
}
